<script lang="ts" setup>
	import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
	import {useWebConfigStore} from "@/stores"
	import { $http, $system, useStorage } from './utils';
 	onLaunch((options : any) => {
		// uni.hideTabBar();
		const storeage = useStorage();
		const appid = options.query?.appid || $system.appid();

		if (appid) {
			// #ifdef H5
			storeage.set('APPID', appid);
			// #endif
		} else {
			uni.showModal({
				content: '授权地址不正确，请重新访问',
				showCancel: false
				, success() {
					// #ifdef H5
					globalThis.close();
					// #endif
					// #ifdef MP-WEIXIN
					uni.navigateBack();
					// #endif
				}
			})
		}

		const puid = options.query?.puid;
		if (puid && !storeage.get('PUID.' + appid)) {
			storeage.set('PUID.' + appid, puid);
		}
		const webConfigStore=useWebConfigStore();
		webConfigStore.initWebConfig();
		$http.get('Config/getConfig', { data: { type: 'all' } }).then((result : any) => {
			let res = result.data
			webConfigStore.setWebConfig(res).then(()=>{
				uni.$emit('initConfig')
			})
		})
		console.log('App Launch')
	})
	onShow(() => {
		console.log('App Show')
	})
	onHide(() => {
		console.log('App Hide')
	})
</script>

<style lang="scss">
	// #ifdef H5
	* {
		outline: none;
		box-sizing: border-box;
	}

	// #endif
	// #ifdef MP-WEIXIN
	view {
		outline: none;
		box-sizing: border-box;
		font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
	}

	// #endif
	/*每个页面公共css */
	@import "static/common.scss";

	page {
		background-color: #f4f8fb;
	}

	.text-shadow {

		text-shadow: 1px 1px #000000,
			-1px -1px #000000,
			1px -1px #000000,
			-1px 1px #000000;
	}
</style>